import 'package:flutter/material.dart';
import 'package:tiktokadult/assets_tool/app_colors.dart';
import 'package:tiktokadult/assets_tool/images.dart';
import 'package:tiktokadult/hj_model/acg/comic_chapters_model.dart';
import 'package:tiktokadult/hj_utils/widget_utils.dart';

import '../../live/live_widget.dart';

class AcgSymbolWidget extends StatelessWidget {
  final ComicChapterInfo? info;
  const AcgSymbolWidget({super.key, this.info});

  @override
  Widget build(BuildContext context) {
    if (info?.hasBuy == true) {
      return Container(
          alignment: Alignment.center,
          height: 17,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(9),
              bottomRight: Radius.circular(9),
            ),
            color: AppColors.primaryHighColor,
          ),
          padding: EdgeInsets.symmetric(horizontal: 6),
          child: Text(
            '已解锁',
            style: textStyle(10, Colors.white, FontWeight.w400),
          ));
    } else if (info?.listenPermission == 1) {
      return Container(
        alignment: Alignment.center,
        height: 17,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(9),
            bottomRight: Radius.circular(9),
          ),
          color: AppColors.primaryHighColor,
        ),
        padding: EdgeInsets.symmetric(horizontal: 6),
        child: Row(
          children: [
            Image.asset('acg_coin.png'.commonImgPath, width: 12),
            2.sizeBoxW,
            Text(
              '${info?.price ?? 0}',
              style: textStyle(10, Colors.white, FontWeight.w400),
            ),
          ],
        ),
      );
    }

    return SizedBox.shrink();
  }
}

class CartoonEpisodesItem extends StatelessWidget {
  final bool sel;
  final int index;
  final ComicChapterInfo? info;
  const CartoonEpisodesItem({super.key, this.sel = false, this.index = 0, this.info});

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Container(
          width: 56,
          height: 56,
          alignment: Alignment.center,
          decoration: BoxDecoration(
              color: sel ? Color(0xffFFD300).withOpacity(.1) : Color(0xff141414),
              borderRadius: BorderRadius.circular(8),
              border: Border.all(
                width: 1,
                color: sel ? AppColors.primaryHighColor : Color(0xff4B4B4B),
              )),
          child: sel
              ? Transform.translate(
                  offset: Offset(0, info?.listenPermission == 1 ? 5 : 0),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Text(
                        '${index + 1}',
                        textAlign: TextAlign.center,
                        style: TextStyle(
                          color: AppColors.primaryHighColor,
                          fontSize: sel ? 14 : 16,
                          fontWeight: FontWeight.w400,
                        ),
                      ),
                      5.sizeBoxW,
                      AudioWaveView(
                        color: AppColors.primaryHighColor,
                        height: 10,
                      ),
                    ],
                  ),
                )
              : Text(
                  '${index + 1}',
                  textAlign: TextAlign.center,
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: sel ? 14 : 16,
                    fontWeight: FontWeight.w400,
                  ),
                ),
        ),
        Positioned(top: 0, left: 0, child: AcgSymbolWidget(info: info)),
      ],
    );
  }
}
